<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShippingTemplateRulesTable extends Migrator
{
    public function change()
    {
        $table = $this->table('shipping_template_rules');
        $table->setId('id')
            ->addColumn('template_id', 'integer', ['comment' => '运费模板ID'])
            ->addColumn('first', 'decimal', ['precision' => 10, 'scale' => 3, 'comment' => '首件/首重/首体积'])
            ->addColumn('first_price', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '首件/首重/首体积费用'])
            ->addColumn('next_price', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '续件/续重/续体积费用'])
            ->addColumn('area_type', 'string', ['limit' => 20, 'comment' => '区域类型: default(默认), special(特殊区域)'])
            ->addColumn('area_name', 'string', ['limit' => 100, 'comment' => '区域名称，如:偏远地区、江浙沪等', 'null' => true])
            ->addColumn('regions', 'json', ['comment' => '地区信息(JSON格式，省级行政区划，包含地区编码和名称)', 'null' => true])
            ->addTimestamps('create_time', 'update_time')
            ->addIndex(['template_id'])
            ->addIndex(['area_type'])
            ->create();
    }
}